home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
UTILITIE
/
CONVERSI
/
1396.ZIP
/
ANAG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-01-12
|
1KB
|
57 lines
; ******************
; * Anagram Finder *
; * by Robin Nixon *
; * (C) PC Amstrad *
; ******************
;
; C source code listing
;
#include "stdio.h"
int len, count=0, level=0;
char string2[16], dummy[16]=" ";
main(argc,argv)
int argc;
char argv[];
{
char string[16];
if (argc < 2)
{
printf("Use: ANAG word");
exit();
}
len=strlen(argv[2]);
if (len > 15)
{
printf("String too long (Max 15 characters)");
exit();
}
strcpy(string,argv[2]) ;
strcpy(string2,argv[2]) ;
dummy[16-len]='\0';
sel(string);
}
int sel(string)
char *string;
{
int j;
char s1[16];
for (j=0 ; j<len ; ++j)
{
strcpy(s1,string);
if (s1[j] != ' ')
{
string2[level++]=s1[j];
if (level == len)
printf("%s%s",string2,dummy);
s1[j]=' ';
sel(s1);
}
}
--level;
}